package com.example.jiemian.UI;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.jiemian.R;
import com.example.jiemian.adapter.PinglunAdapter;
import com.example.jiemian.bean.Luntan;
import com.example.jiemian.bean.Pinglun;
import com.example.jiemian.sqlite.PinglunDBUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class XiaoxiActivity extends AppCompatActivity {
    PinglunAdapter pinglunAdapter;
    @BindView(R.id.rl_back)
    RelativeLayout rlBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_right)
    ImageView tvRight;
    @BindView(R.id.rl_pinglun)
    RecyclerView rlPinglun;
    List<Pinglun> pinglunList;
    int luntan_id;
    Luntan luntan;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_xiaoxi);
        ButterKnife.bind(this);
        tvTitle.setText("我的消息");
        luntan_id = getIntent().getIntExtra("detail",0);
        luntan=(Luntan)getIntent().getSerializableExtra("zuozhe");
        pinglunList = PinglunDBUtils.getInstance(getApplicationContext()).findAllByzuozhe(MyApplication.getInstance().user.getUsername());
        pinglunAdapter = new PinglunAdapter(XiaoxiActivity.this);
        pinglunAdapter.setNewData(pinglunList);
        rlPinglun.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
        rlPinglun.addItemDecoration(new DividerItemDecoration(getApplicationContext(), DividerItemDecoration.VERTICAL));
        pinglunAdapter.bindToRecyclerView(rlPinglun);
        pinglunAdapter.disableLoadMoreIfNotFullPage();
    }

    @OnClick({R.id.rl_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_back:
                finish();
                break;
        }
    }
}